﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Linq;
using System.Windows.Forms;
using DevExpress.XtraEditors;

namespace POS
{
    public partial class NumberPad : DevExpress.XtraEditors.XtraForm
    {
        public int employeeID = 0;
        public int password = 0;
        public bool UserAccepted;
        
        public NumberPad()
        {
            InitializeComponent();
        }

        private void btnNumber_Click(object sender, EventArgs e)
        {
            var button = (SimpleButton)sender;

            textEdit1.Text += button.Text;
        }

        private void btnCLR_Click(object sender, EventArgs e)
        {
            textEdit1.Text = "";
        }

        private void btnENTER_Click(object sender, EventArgs e)
        {
            if (employeeID == 0)
            {
                try
                {
                    employeeID = Convert.ToInt32(textEdit1.Text);
                    textEdit1.Text = "";
                }
                catch
                {
                    textEdit1.Text = "";
                }

            }
            else
            {
                try
                {
                    password = Convert.ToInt32(textEdit1.Text);
                    UserAccepted = StaticProperties.checkLogin(employeeID, password);
                    //MessageBox.Show(employeeID.ToString() + "       " + password.ToString());

                    if (UserAccepted)
                    {
                        MainProgram._Main.panelControl1.Controls.Clear();
                        MainProgram._Main.panelControl1.Controls.Add(new ClockINOUTScreen());
                        this.Close();
                    }
                    else
                    {
                        textEdit1.Text = "Username and Password didn't Match";//. Please Try Again";
                        //textEdit1.Text = "";
                        employeeID = 0;
                        password = 0;
                    }
                }
                catch
                {
                    textEdit1.Text = "Username and Password didn't Match";//. Please Try Again";
                    //textEdit1.Text = "";
                    employeeID = 0;
                    password = 0;
                }

            }
        }
    }
}